package cn.stylefeng.guns.modular.business.frequency.banner.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import cn.stylefeng.guns.modular.business.frequency.banner.service.BannerService;
import cn.stylefeng.guns.modular.business.frequency.banner.model.param.BannerParam;

import javax.annotation.Resource;

/**
 * 轮播图 控制器
 *
 * @author: 刘耀
 * @date: 2022/02/01 11:05
 */
@RestController
public class BannerController {

    @Resource
    private BannerService bannerService;

    /**
     * 分页查询轮播图
     *
     * @author 刘耀
     * @date 2022/02/01 11:05
     */
    @PostMapping("/banner/page")
    @BusinessLog(title = "轮播图_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(@RequestBody BannerParam bannerParam) {
        return new SuccessResponseData(bannerService.page(bannerParam));
    }

    /**
     * 获取全部轮播图
     *
     * @author 刘耀
     * @date 2022/02/01 11:05
     */
    @PostMapping("/banner/list")
    @BusinessLog(title = "轮播图_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(@RequestBody BannerParam bannerParam) {
        return new SuccessResponseData(bannerService.list(bannerParam));
    }

    /**
     * 查看详情轮播图
     *
     * @author 刘耀
     * @date 2022/02/01 11:05
     */
    @PostMapping("/banner/detail")
    @BusinessLog(title = "轮播图_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@RequestBody @Validated(BannerParam.detail.class) BannerParam bannerParam) {
        return new SuccessResponseData(bannerService.detail(bannerParam));
    }

    /**
     * 添加轮播图
     *
     * @author 刘耀
     * @date 2022/02/01 11:05
     */
    @PostMapping("/banner/add")
    @BusinessLog(title = "轮播图_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody  BannerParam bannerParam) {
        bannerService.add(bannerParam);
        return new SuccessResponseData();
    }

    /**
     * 删除轮播图
     *
     * @author 刘耀
     * @date 2022/02/01 11:05
     */
    @PostMapping("/banner/delete")
    @BusinessLog(title = "轮播图_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(BannerParam.delete.class) BannerParam bannerParam) {
        bannerService.delete(bannerParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑轮播图
     *
     * @author 刘耀
     * @date 2022/02/01 11:05
     */
    @PostMapping("/banner/edit")
    @BusinessLog(title = "轮播图_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody BannerParam bannerParam) {
        bannerService.edit(bannerParam);
        return new SuccessResponseData();
    }


}
